package com.potenza.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.streams.KeyValue;
import org.apache.kafka.streams.StreamsBuilder;
import org.apache.kafka.streams.kstream.KStream;

//@Configuration
//@EnableKafkaStreams
public class KafkaStreamsConfiguration {


    //@Bean
    public NewTopic initialTopic_Stream1() {
        return new NewTopic("StreamTopic",8, (short) 2 );
    }

    //@Bean
    public NewTopic initialTopic_Stream2() {
        return new NewTopic("AnotherTopic",8, (short) 2 );
    }
    //@Bean
    public KStream<String, Object> kStream(StreamsBuilder streamsBuilder) {
        KStream<String, Object> stream = streamsBuilder.stream("StreamTopic");
        // 有兴趣可以写个 wordCount
        stream.map((key,value) -> {
            value += "--test--";
            return new KeyValue<>(key,value);
        }).to("AnotherTopic");
        return stream;
    }
}
